<!doctype html>
<html lang="en">
<head>
    @include('web.layout.head')
    <link rel="stylesheet" href="{{asset('/css/web/user/coupon.css')}}">
</head>
<body>
@include('web.layout.header')
@include('web.layout.user_tab')
<div class="base_member_content">
    <div class="w1200">
        @include('web.layout.buyer_nav')
        <div class="nav_right flr">
            <div class="base_content">
                <div class="line_title">我的优惠券</div>
                <div class="my-subnav f-cb">
                    <ul>
                        <li><a href="{{asset('/buyer/coupon')}}" class="jm_hover">可用优惠券</a><i></i></li>
                        <li><a href="{{asset('/buyer/coupon?status=1')}}" class="jm_hover">已使用优惠券</a><i></i></li>
                        <li><a href="{{asset('/buyer/coupon?status=2')}}" class="jm_hover">已过期优惠券</a><i></i></li>
                    </ul>
                    <div class="search">
                        <input name='code' type="text" class="text fl" placeholder="请输入优惠券号" value='' />
                        <input type="submit" class="submit fr" value="查询" />
                        {{csrf_field()}}
                    </div>
                </div>
                <div class="content">
                    <div class="coupon_items">
                    @if(!empty($coupon_list))
                        @foreach($coupon_list as $coupon)
                        <div class="coupon_item fl @if($status!=0){{'coupon_overdue_item'}}@endif">
                            <div class="c_type">
                                <div class="deletebox">
                                    @if($coupon['use_status'] == 'unused')
                                    <a href="javascript:;" data-id="{{$coupon['coupon_id']}}" class="js-remove"><img src="{{'/img/inc/icon/delete.png'}}" alt=""></a>
                                    @endif
                                </div>
                                <div class="c_price">
                                    <em>¥</em>
                                    <strong>{{number_format($coupon['coupon_money'], 2)}}</strong>
                                </div>
                                <div class="c_limit">[{{$coupon['name']}}]</div>
                                <div class="c_time">{{substr($coupon['period_start'], 0, 10)}} 至 {{substr($coupon['period_end'], 0, 10)}}</div>
                            </div>
                            <div class="c_range">
                                <div class="range_item">
                                    <p class="label fl">券号：</p>
                                    <p class="txt fl">{{$coupon['code']}}</p>
                                </div>
                                <div class="range_item">
                                    <p class="label fl">规则：</p>
                                    <p class="txt fl">{{$coupon['summary']}}</p>
                                </div>
                            </div>
                            <div class="use_content">
                                <!-- <a href="javascript:;" class="useWay useWayNow fl"><i>券使用说明 ></i></a> -->
                                @if($coupon['use_status'] == 'unused' && strtotime($coupon['period_end']) <= time())
                                <span class="overdate_flag">已过期</span>
                                @elseif($coupon['use_status'] == 'used')
                                <span class="overdate_flag">已使用</span>
                                @else
                                <span class="overdate_flag">未使用</span>
                                @endif
                            </div>
                        </div>
                        @endforeach
                    @endif
                    </div>
                    <div class="page">
                        
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@include('web.layout.footer')
<script>
    $(function () {
        $(".js-remove").click(function () {
            var $this = $(this), cid = $this.data('id');
            var token = $(".base_content").find('input[name="_token"]').val();
            $.post('/buyer/coupon_remove', {_token: token, id: cid}, function (res) {
                if (res.err == 0){
                    $this.parents('.coupon_item').remove();
                } else {
                    $.MsgBox.Alert("温馨提示", res.errmsg);
                }
            }, 'json')
        })
    })
</script>
</body>
</html>